home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
SAT 2.3b4
/
Demo ƒ
/
SATminimal demo ƒ
/
sMySprite.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-22
|
1KB
|
51 lines
#include "SAT.h"
Handle theSound;
FacePtr faces[6];
/* Prototypes */
void InitMySprite();
pascal void SetupMySprite (SpritePtr);
pascal void HandleMySprite (SpritePtr);
void InitMySprite()
{
int i;
theSound = SATGetSound(128); /*Preload the sound */
for (i=0; i<=5; i++)
faces[i] = SATGetFace(128+i); /* Preload all sprite faces */
}
/* Important! Callback routines (Setup, Handle, Hit) must be declared "pascal"! */
pascal void SetupMySprite (me)
SpritePtr me;
{
me->mode = 0; /* Pick a valid face number */
me->speed.h = 2; /* Set the speed - only horizontal is used here */
me->task = HandleMySprite; /* Set a handling routine. MANDATORY! If nil, the sprite will self-destruct. */
}
pascal void HandleMySprite (me)
SpritePtr me;
{
/* Choose face */
me->mode = (me->mode + 1) % 6;
me->face = faces[me->mode];
/* Move */
me->position.h = me->position.h + me->speed.h;
if (me->position.h > gSAT.offSizeH - 16)
{
me->speed.h = -2;
SATSoundPlay(theSound, 1, false);
};
if (me->position.h < -16)
{
me->speed.h = 2;
SATSoundPlay(theSound, 1, false);
};
}